<template>
<div>
  <el-form ref="dataForm" :model="form" class="el-dialog__body" label-width="100px">
    <el-row>
      <el-col :span="6">
        <el-form-item label="记录人:" prop="recordName">
          {{form.recordName}}
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label-width="100px" label="记录日期:">
          {{form.recordDate}}
        </el-form-item>
      </el-col>
    </el-row>
    <div class="ledgerTitle">项目信息</div>
    <el-row>
      <el-col :span="12">
        <el-form-item label-width="100px" label="项目名称:" prop="projectName">
          {{form.projectName}}
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label-width="100px" label="审计重点:" prop="projectName">
          {{form.keynoteTitle}}
        </el-form-item>
      </el-col>
    </el-row>
    <div class="ledgerTitle">审计疑点</div>
    <el-row>
      <el-col :span="6">
        <el-form-item label-width="100px" label="是否落实:" prop="fix">
          <div v-if="Number(form.fix) === 0">
            <span>是</span>
          </div>
          <div v-else>
            <span>否</span>
          </div>
        </el-form-item>
      </el-col>
      <el-col :span="6">
        <el-form-item label-width="100px" label="形成问题:" prop="discovery">
          <div v-if="Number(form.discovery) === 0">
            <span>是</span>
          </div>
          <div v-else>
            <span>否</span>
          </div>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col>
        <el-form-item label-width="100px"  label="疑点描述:" prop="pointDesc">
          <pre class="pre-style">{{ form.pointDesc }}</pre>
        </el-form-item>
      </el-col>
    </el-row>
    <div class="ledgerTitle">审计证据</div>
    <el-row>
      <el-col :span="24">
        <el-table
          ref="table"
          :data="tableData"
          :model="tableData"
          style="width: 100%"
          highlight-current-row
          >
          <el-table-column label="序号" width="50">
            <template #default="{ row, $index }">
              <span>{{ $index+1}}</span>
            </template>
          </el-table-column>
          <el-table-column label="证据类别">
            <template #default="{ row }">
              <DictTag :options="dict.type.evidence_type" :value="row.evidenceType"></DictTag>
            </template>
          </el-table-column>
          <el-table-column label="取证日期">
            <template #default="{ row }">
              {{row.evidenceDate}}
            </template>
          </el-table-column>
          <el-table-column label="相关附件">
            <template #default="{ row }">
              <el-upload
                class="upload-demo"
                action="/admin/sys-file/upload"
                :on-preview="handlePreview"
                :show-file-list="true"
                :file-list="row.fileList">
              </el-upload>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
  </el-form>
</div>
</template>

<script>
  import {getByPointId} from "@/api/adis/execute/point";

  export default {
    name:'DoubtfulView',
    props:{
      id: {
        type: String,
        default: ''
      },
      params:{
        type: Object,
      },
      isAudit: {
        type: Boolean,
        default: false,
      }
    },
    components: {},
    dictTypes: ['evidence_type'],
    data(){
      return{
        form:{},
        tableData:[],
      }
    },
    watch:{
      id: {
        handler(val){
          if (val){
            getByPointId(val).then((res) => {
              if (res.data.data !== null){
                this.handleDoubtfulResponse(res.data.data)
                this.$emit('data-loaded', true);
              } else {
                this.$emit('data-loaded', false);
              }
            }).catch(() => {
              this.$emit('data-loaded', false);
            });
          }
        },deep: true, immediate: true
      },
      params: {
        handler(val) {
          if (val) {
            this.handleDoubtfulResponse(val)
          }
        },deep: true, immediate: true
      },
    },
    methods:{
      handleDoubtfulResponse(val) {
        this.$set(this, "form", val);
        this.form.auditArrayTime = [this.form.auditStartDate, this.form.auditEndDate];
        this.form.recordName = this.form.createBy;
        this.form.recordDate = this.form.createTime;

        this.tableData = val.projectPointAttachments || [];
        this.tableData.forEach(item => {
          item.fileList = [];
          item.attachments.forEach(col => {
            item.fileList.push({ name: col.fileName, url: col.fileUrl });
          });
        });
      },
      handlePreview(file) {
        window.open(file.url ? file.url : file.response.data.url)
      },
    }
  }
</script>
<style>

</style>
